<?php
@header('Content-type: text/html;charset=UTF-8');
require_once('check.php');
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>站点类型编辑</title>
    <link rel="stylesheet" href="../images/css.css" type="text/css"/>
    <script type="text/javascript">
        function check() {
            var serviceStationName = document.getElementById("serviceStationName");
            var serviceStationPwd = document.getElementById("serviceStationPwd");
            if (trim(serviceStationName.value) == null || trim(serviceStationName.value) == "") {
                alert("请输入站点名称");
                serviceStationName.focus();
                return false;
            }
            if (trim(serviceStationPwd.value) == null || trim(serviceStationPwd.value) == "") {
                alert("请输入站点密码");
                serviceStationPwd.focus();
                return false;
            }


            return true;
        }
        function trim(str) { //删除左右两端的空格
            return str.replace(/(^\s*)|(\s*$)/g, "");
        }
    </script>
</head>
<body>
<?php
if ($_POST["Submit"]) {
    $id = $_POST["id"];
    $serviceStationName = str_replace(' ', '', $_POST["serviceStationName"]);
    $countyTypeId = str_replace(' ', '', $_POST["countyTypeId"]);
    $memo = str_replace(' ', '', $_POST["memo"]);
    $sql = "update servicestation set serviceStationName='$serviceStationName',countyTypeId='$countyTypeId', memo='$memo' where Id=$id";
    mysql_query($sql);
    header("location:index.php?pageno=$pageno");
}
$id = $_GET["id"];
$pageno = $_GET["pageno"];

$sql = "select * from servicestation where id=$id";
$rs = mysql_query($sql);
if (mysql_num_rows($rs) != 0) {
    while ($rows = mysql_fetch_assoc($rs)) {
        ?>
        <form id="form1" name="form1" method="post" action=""
              onsubmit="return check();">
            <table width="100%" border="0" align="center" cellpadding="5"
                   cellspacing="1" bordercolor="#000000" bgcolor="#cccccc">
                <tr>
                    <th colspan="2" bgcolor="#FFFFFF">修改站点类型</th>
                </tr>
                <tr>
                    <td bgcolor="#FFFFFF" class="forumRowHighlight">站点编号:</td>
                    <td bgcolor="#FFFFFF" class="forumRowHighlight"><span><?php echo $rows["serviceStationId"] ?></span>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#FFFFFF" class="forumRowHighlight">站点名称:</td>
                    <td bgcolor="#FFFFFF" class="forumRowHighlight"><input type="text"
                                                                           name="serviceStationName"
                                                                           id="serviceStationName" style="width:240px;"
                                                                           value="<?php echo $rows["serviceStationName"] ?>"/>*
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#FFFFFF" class="forumRowHighlight">站点类型:</td>
                    <td bgcolor="#FFFFFF" class="forumRowHighlight"><select
                                id="countyTypeId" name="countyTypeId">
                            <?php
                            $sql1 = "select * from countytype order by id desc";
                            $rs1 = mysql_query($sql1);
                            while ($rows1 = mysql_fetch_assoc($rs1)) {
                                ?>
                                <option value="<?php echo $rows1["countyTypeId"] ?>"
                                    <?php if ($rows["countyTypeId"] == $rows1["countyTypeId"]) {
                                        echo "selected='selected'";
                                    } ?>><?php echo $rows1["countyTypeName"] ?></option>
                                <?php
                            }
                            ?>
                        </select></td>
                </tr>
                <tr>
                    <td bgcolor="#FFFFFF" class="forumRowHighlight">站点说明:</td>
                    <td bgcolor="#FFFFFF" class="forumRowHighlight"><textarea rows="5"
                                                                              cols="15"
                                                                              name="memo"><?php echo $rows["memo"] ?></textarea>
                    </td>
                </tr>

                <tr>
                    <td colspan="2" align="center"><input type="hidden" name="id"
                                                          value="<?php echo $rows["Id"] ?>"/> <input name="Submit"
                                                                                                     type="submit"
                                                                                                     class="button"
                                                                                                     value="提交"/> &nbsp;
                        <input
                                name="reset" type="reset" class="button" value="重置"/></td>
                </tr>
            </table>
        </form>
        <?php
    }
}
?>
</body>
</html>